package com.example.calender.persistence;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Flowable;

@Dao
public interface UserDao {

    @Query("SELECT * FROM users LIMIT 1")
    Flowable<User> getUser();

    @Query("SELECT * FROM users WHERE username LIKE :name LIMIT 1")
    User findByName(String name);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Completable insertUser(User user);

    @Insert
    Completable insert(User user);

    @Query("DELETE FROM Users")
    void deleteAllUsers();
}
